package mine.threading;

public class FaultyStop {

	private boolean stopMe = false;
	
	public void methodRunByThread1() {
		while(!stopMe) {
			// doing some work
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {}
		}
	}
	
	public void methodRunByThread2() {
		stopMe = true;
	}
	
	public static void main(String[] args) {
		final FaultyStop a = new FaultyStop();
		
		Thread t1 = new Thread(){
			public void run() {
				a.methodRunByThread1();
			}			
		};
		
		Thread t2 = new Thread(){
			public void run() {
				a.methodRunByThread2();
			}
		};
		
		t1.start();
		t2.start();
	}
	
}
